#pragma once

/// <summary>
/// GeometryFactory: Factory class that generates vertex and index buffers
/// <summary>

/**	
  * Author: Dane Bulat
  * Created: 06/2013
  * Last Modified: 30/06/13
  * Version: v1.0
  */

// Includes
#include "common/GeometryGenerator.h"
#include "BasicShader.h"

// Class Definition
class GeometryFactory
{
public:
//==============================
// Constructors / Destructors
//==============================

	/// Default Constructor
	GeometryFactory();

	/// Default Destructor
	~GeometryFactory();

//==============================
// Geometry Creation
//==============================

	// BOX

  /**
	* Create Box Vertex Buffers.
	* @param D3D Device Pointer.
	* @return Vertex Buffer containing box data.
	*/
	ID3D11Buffer* create_box_vb(ID3D11Device* device);

  /**
	* Create Box Index Buffers.
	* @param D3D Device Pointer.
	* @return Index Buffer containing box data.
	*/
	ID3D11Buffer* create_box_ib(ID3D11Device* device);

	// SPHERE

  /**
	* Create Sphere Vertex Buffers.
	* @param D3D Device Pointer.
	* @param Radius of the sphere.
	* @param Number of vertical slices.
	* @param Number of horizontal stacks.
	* @return Vertex Buffer containing sphere data.
	*/
	ID3D11Buffer* create_sphere_vb(ID3D11Device* device, float radius, UINT sliceCount, UINT stackCount);

  /**
	* Create Sphere Index Buffers.
	* @param D3D Device Pointer.
	* @param Radius of the sphere.
	* @param Number of vertical slices.
	* @param Number of horizontal stacks.
	* @return Index Buffer containing sphere data.
	*/
	ID3D11Buffer* create_sphere_ib(ID3D11Device* device, float radius, UINT sliceCount, UINT stackCount);

  /**
	* Create Geosphere Vertex Buffers.
	* @param D3D Device Pointer.
	* @param Radius of the sphere.
	* @param Number of face subdivisions.
	* @return Vertex Buffer containing Geosphere data.
	*/
	ID3D11Buffer* create_geosphere_vb(ID3D11Device* device, float radius, UINT subdivisions);

  /**
	* Create Geosphere Index Buffers.
	* @param D3D Device Pointer.
	* @param Radius of the sphere.
	* @param Number of face subdivisions.
	* @return Index Buffer containing Geosphere data.
	*/
	ID3D11Buffer* create_geosphere_ib(ID3D11Device* device, float radius, UINT subdivisions);

  /**
	* Create Cylinder Vertex Buffers.
	* @param D3D Device Pointer.
	* @param Radius of the bottom of the cylinder.
	* @param Radius of the top of the cylinder.
	* @param Height of the cylinder.
	* @param Number of vertical slices.
	* @param Number of horizontal stacks.
	* @return Vertex Buffer containing cylinder data.
	*/
	ID3D11Buffer* create_cylinder_vb(ID3D11Device* device, float bottomRadius, float topRadius, float height, UINT sliceCount, UINT stackCount);

  /**
	* Create Cylinder Index Buffers.
	* @param D3D Device Pointer.
	* @param Radius of the bottom of the cylinder.
	* @param Radius of the top of the cylinder.
	* @param Height of the cylinder.
	* @param Number of vertical slices.
	* @param Number of horizontal stacks.
	* @return Vertex Index containing cylinder data.
	*/
	ID3D11Buffer* create_cylinder_ib(ID3D11Device* device, float bottomRadius, float topRadius, float height, UINT sliceCount, UINT stackCount);
	
  /**
	* Create Grid Vertex Buffers.
	* @param D3D Device Pointer.
	* @param Width of the grid.
	* @param Depth of the grid.
	* @param Number of X Segments.
	* @param Number of Z Segments.
	* @return Vertex Buffer containing grid data.
	*/
	ID3D11Buffer* create_grid_vb(ID3D11Device* device, float width, float depth, UINT xseg, UINT zseg);

  /**
	* Create Grid Index Buffers.
	* @param D3D Device Pointer.
	* @param Width of the grid.
	* @param Depth of the grid.
	* @param Number of X Segments.
	* @param Number of Z Segments.
	* @return Index Buffer containing grid data.
	*/
	ID3D11Buffer* create_grid_ib(ID3D11Device* device, float width, float depth, UINT xseg, UINT zseg);

private:
	GeometryGenerator	m_geoGen;	///< Geometry Generator Helper Class.
	HRESULT				m_hr;		///< HRESULT for debug and error checking.
};